package com.cloud.sample.stomp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

@Component
public class StompProvider {
    public static final String SUBSCRIBE_PREFIX = "/topic/im/";

    @Autowired
    private SimpMessagingTemplate simpMessagingTemplate;

    public void push(StompMsgDTO msgDTO) {
        simpMessagingTemplate.convertAndSend(SUBSCRIBE_PREFIX + msgDTO.getReceiverId(), msgDTO);
    }
}
